using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Data;
using System.Data.Odbc;

namespace DAO
{
    public class DataProvider
    {
        protected static string _connectionString;
        protected OdbcConnection connection;
        protected OdbcDataAdapter adapter;
        protected OdbcCommand command;


        public static string ConnectionString
        {
            get
            {
                return _connectionString;
            }
            set
            {
                _connectionString = value;
            }
        }

        public void connect()
        {
            _connectionString = ConfigurationManager.ConnectionStrings["ODBC"].ToString();
            connection = new OdbcConnection();
            connection.ConnectionString = ConnectionString;
            connection.Open();
        }

        public void disconnect()
        {
            connection.Close();
        }

        public IDataReader executeQuery(string OdbcString)
        {
            command = new OdbcCommand(OdbcString, connection);
            return command.ExecuteReader();
        }

        public void executeNonQuery(string OdbcString)
        {
            command = new OdbcCommand(OdbcString, connection);
            command.ExecuteNonQuery();
        }

        public object executeScalar(string OdbcString)
        {
            command = new OdbcCommand(OdbcString, connection);
            return command.ExecuteScalar();
        }
        public OdbcDataAdapter OdbcAdapter(string odbc)
        {
            adapter = new OdbcDataAdapter(odbc, connection);
            return adapter;
        }

        

    }
}
